package com.menu.Controller;

import com.menu.Service.DataService;
import com.menu.Service.GoodsService;
import com.menu.Service.OrderService;
import com.menu.Service.UserService;
import com.menu.Utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "管理员实时数据取值")
@RestController
@RequestMapping("/Admin")
public class DataController {

    @Autowired
    private GoodsService goodsService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private UserService userService;
    @Autowired
    private DataService dataService;

    @ApiOperation("获取商品概况近百天的点击量")
    @GetMapping("/getVisit")
    public ResponseResult getVisitNumber(){
        return goodsService.getVisitNumber();
    }

    @ApiOperation("获取近百天的销售量")
    @GetMapping("/getSalesNumber")
    public ResponseResult getSalesNumber(){
        return orderService.getSalesNumber();
    }

    @ApiOperation("商品概况页")
    @GetMapping("/realData")
    public ResponseResult realData (){
        return orderService.realData();
    }


    @ApiOperation("男女比例")
    @GetMapping("/rateSex")
    public ResponseResult rateSex(){
        return userService.rateSex();
    }

    @ApiOperation("年龄分布")
    @GetMapping("/rateAge")
    public ResponseResult rateAge(){
        return userService.rateAge();
    }

    @ApiOperation("商品排行")
    @GetMapping("/commodityList")
    public ResponseResult commodityList(){
        return orderService.commodityList();
    }

    @ApiOperation("获取商品发货情况")
    @GetMapping("/deliverySituation")
    public ResponseResult deliverySituation(){
        return orderService.deliverySituation();
    }

    @ApiOperation("获取热搜关键词")
    @GetMapping("/getHotSearch")
    public ResponseResult getHotSearch(){
        return goodsService.getHotSearch();
    }

    @ApiOperation("获取周成交率 返回的数据最靠前的为最新")
    @GetMapping("/turnoverWeekRatio")
    public ResponseResult turnoverWeekRatio(){
        return dataService.turnoverRatio(0);
    }

    @ApiOperation("获取月成交率")
    @GetMapping("/turnoverMonthRatio")
    public ResponseResult turnoverMonthRatio(){
        return dataService.turnoverRatio(1);
    }

    @ApiOperation("获取年成交率")
    @GetMapping("/turnoverYearRatio")
    public ResponseResult turnoverYearRatio(){
        return dataService.turnoverRatio(2);
    }


    @ApiOperation("获取各省市成交数")
    @GetMapping("/regionalPurchase")
    public ResponseResult regionalPurchase(){
        return orderService.regionalPurchase();
    }

    @ApiOperation("查询总成交数")
    @GetMapping("/getFinish")
    public ResponseResult getFinish(){
        return orderService.getFinish();
    }

    @ApiOperation("24小时流量走势")
    @GetMapping("/hourTrend")
    public ResponseResult hourTrend(){
        return dataService.hourTrend();
    }

    @ApiOperation("日访问量/较昨日")
    @GetMapping("/fromYesterday")
    public ResponseResult fromYesterday(){
        return dataService.fromPre(0);
    }

    @ApiOperation("周访问量/较昨周")
    @GetMapping("/fromWeek")
    public ResponseResult fromWeek(){
        return dataService.fromPre(1);
    }

    @ApiOperation("月访问量/较昨月")
    @GetMapping("/fromMonth")
    public ResponseResult fromMonth(){
        return dataService.fromPre(2);
    }

    @ApiOperation("年访问量/较昨年")
    @GetMapping("/fromYear")
    public ResponseResult fromYear(){
        return dataService.fromPre(3);
    }

    @ApiOperation("获取年访问量")
    @GetMapping("/annualVisits")
    public ResponseResult annualVisits(){
        return dataService.annualVisits();
    }

    @ApiOperation("获取年销售量")
    @GetMapping("/annualSales")
    public ResponseResult annualSales(){
        return dataService.annualSales();
    }
}
